<template>
  <div>
    <h1>借款用户登录页面</h1>
<table>
  <tr>
    <td>账号：</td>
    <td><input type="text" v-model="state.JName"></td>
  </tr>
  <tr>
    <td>密码：</td>
    <td><input type="password" v-model="state.JPwd"></td>
  </tr>
  <tr>
    <td></td>
    <td><input type="button" value="登录" @click="lu"></td>
  </tr>
</table>
  </div>
</template>

<script setup lang="ts">
import {reactive,toRefs} from 'vue'
import axios from 'axios'
import {useRoute,useRouter} from 'vue-router'
const route=useRoute()
const router=useRouter()

let data=reactive({
  state:{
    JName:'',
    JPwd:''
  }
})

let {state}=toRefs(data)

const lu=()=>{
  axios({
    url:'/api/JieKuan/GetJieKuanDengLu',
    method:'get',
    params:state.value
  })
  .then(res=>{
    console.log(res);
    
    if(res.data.data==1){
      alert('管理员登录成功');
      router.push('/adminjiekuan');
    }
    else if(res.data.data==2){
      alert('普通用户登录成功');
      router.push('/userjiekuan');
    }
    else if(res.data.data==-1){
      alert('该用户不存在');
      return;
    }
    else if(res.data.data==-2){
      alert('账号或密码不正确');
      return;
    }
  })
}
</script>

<style scoped>

</style>